#Boa:Frame:Frame_EfetuarPagamento

import wx
import random
import datetime
from ControleCliente import *
from ControleServico import *
from ControleAgendamento import *
from ControlePagamento import *

def create(parent, user, ID):
    return Frame_EfetuarPagamento(parent, user, ID)

[wxID_FRAME_EFETUARPAGAMENTO, wxID_FRAME_EFETUARPAGAMENTOBUTTON1, 
 wxID_FRAME_EFETUARPAGAMENTOBUTTON2, wxID_FRAME_EFETUARPAGAMENTOBUTTON3, 
 wxID_FRAME_EFETUARPAGAMENTOBUTTON4, wxID_FRAME_EFETUARPAGAMENTOCHOICE1, 
 wxID_FRAME_EFETUARPAGAMENTOLISTBOX1, wxID_FRAME_EFETUARPAGAMENTOPANEL1, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICBOX1, wxID_FRAME_EFETUARPAGAMENTOSTATICBOX2, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICBOX3, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICLINE1, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT1, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT2, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT3, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT6, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT7, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT8, 
 wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT9, wxID_FRAME_EFETUARPAGAMENTOWINDOW1, 
 wxID_FRAME_EFETUARPAGAMENTOWINDOW2, wxID_FRAME_EFETUARPAGAMENTOWINDOW3, 
] = [wx.NewId() for _init_ctrls in range(22)]

class Frame_EfetuarPagamento(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME_EFETUARPAGAMENTO,
              name=u'Frame_EfetuarPagamento', parent=prnt, pos=wx.Point(446,
              89), size=wx.Size(576, 564), style=wx.DEFAULT_FRAME_STYLE,
              title=u'Frame_EfetuarPagamento')
        self.SetClientSize(wx.Size(560, 526))

        self.panel1 = wx.Panel(id=wxID_FRAME_EFETUARPAGAMENTOPANEL1,
              name='panel1', parent=self, pos=wx.Point(0, 0), size=wx.Size(560,
              526), style=wx.TAB_TRAVERSAL)
        self.panel1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Tahoma'))

        self.staticText1 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT1,
              label=u'Efetuar Pagamento', name='staticText1',
              parent=self.panel1, pos=wx.Point(166, 16), size=wx.Size(228, 33),
              style=0)
        self.staticText1.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))
        self.staticText1.Center(wx.HORIZONTAL)

        self.staticLine1 = wx.StaticLine(id=wxID_FRAME_EFETUARPAGAMENTOSTATICLINE1,
              name='staticLine1', parent=self.panel1, pos=wx.Point(136, 64),
              size=wx.Size(287, 2), style=0)
        self.staticLine1.Center(wx.HORIZONTAL)

        self.window1 = wx.Window(id=wxID_FRAME_EFETUARPAGAMENTOWINDOW1,
              name='window1', parent=self.panel1, pos=wx.Point(32, 112),
              size=wx.Size(232, 168), style=0)
        self.window1.SetBackgroundColour(wx.Colour(226, 226, 226))

        self.staticBox1 = wx.StaticBox(id=wxID_FRAME_EFETUARPAGAMENTOSTATICBOX1,
              label=u'Informa\xe7\xf5es', name='staticBox1',
              parent=self.window1, pos=wx.Point(8, 8), size=wx.Size(208, 152),
              style=0)
        self.staticBox1.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))

        self.staticText2 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT2,
              label=u'<ID>', name='staticText2', parent=self.window1,
              pos=wx.Point(32, 32), size=wx.Size(41, 19), style=0)
        self.staticText2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))
        self.staticText2.Show(False)

        self.staticText3 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT3,
              label=u'<Nome>', name='staticText3', parent=self.window1,
              pos=wx.Point(24, 96), size=wx.Size(50, 14), style=0)
        self.staticText3.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))
        self.staticText3.Show(False)

        self.window2 = wx.Window(id=wxID_FRAME_EFETUARPAGAMENTOWINDOW2,
              name='window2', parent=self.panel1, pos=wx.Point(272, 112),
              size=wx.Size(256, 224), style=0)
        self.window2.SetBackgroundColour(wx.Colour(221, 221, 221))

        self.staticBox2 = wx.StaticBox(id=wxID_FRAME_EFETUARPAGAMENTOSTATICBOX2,
              label=u'Servi\xe7os Feitos', name='staticBox2',
              parent=self.window2, pos=wx.Point(8, 8), size=wx.Size(240, 208),
              style=0)
        self.staticBox2.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))

        self.button1 = wx.Button(id=wxID_FRAME_EFETUARPAGAMENTOBUTTON1,
              label=u'Selecionar Cliente', name='button1', parent=self.panel1,
              pos=wx.Point(32, 288), size=wx.Size(112, 32), style=0)
        self.button1.Show(False)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME_EFETUARPAGAMENTOBUTTON1)

        self.button2 = wx.Button(id=wxID_FRAME_EFETUARPAGAMENTOBUTTON2,
              label=u'Adicionar Servi\xe7o', name='button2', parent=self.panel1,
              pos=wx.Point(152, 288), size=wx.Size(112, 32), style=0)
        self.button2.Show(False)

        self.window3 = wx.Window(id=wxID_FRAME_EFETUARPAGAMENTOWINDOW3,
              name='window3', parent=self.panel1, pos=wx.Point(32, 344),
              size=wx.Size(496, 120), style=0)
        self.window3.SetBackgroundColour(wx.Colour(225, 225, 225))
        self.window3.Center(wx.HORIZONTAL)

        self.staticBox3 = wx.StaticBox(id=wxID_FRAME_EFETUARPAGAMENTOSTATICBOX3,
              label=u'Informa\xe7\xf5es de Pagamento', name='staticBox3',
              parent=self.window3, pos=wx.Point(8, 0), size=wx.Size(480, 112),
              style=0)
        self.staticBox3.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))

        self.staticText6 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT6,
              label=u'Total', name='staticText6', parent=self.window3,
              pos=wx.Point(24, 32), size=wx.Size(33, 16), style=0)
        self.staticText6.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Tahoma'))

        self.staticText7 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT7,
              label=u'<Valor>', name='staticText7', parent=self.window3,
              pos=wx.Point(72, 32), size=wx.Size(48, 16), style=0)
        self.staticText7.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))
        self.staticText7.Show(False)
        self.staticText7.SetForegroundColour(wx.Colour(255, 0, 0))

        self.staticText8 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT8,
              label=u'R$', name='staticText8', parent=self.window3,
              pos=wx.Point(128, 32), size=wx.Size(15, 13), style=0)
        self.staticText8.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Tahoma'))

        self.staticText9 = wx.StaticText(id=wxID_FRAME_EFETUARPAGAMENTOSTATICTEXT9,
              label=u'Modo de Pagamento', name='staticText9',
              parent=self.window3, pos=wx.Point(24, 72), size=wx.Size(132, 16),
              style=0)
        self.staticText9.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Tahoma'))

        self.choice1 = wx.Choice(choices=[],
              id=wxID_FRAME_EFETUARPAGAMENTOCHOICE1, name='choice1',
              parent=self.window3, pos=wx.Point(168, 64), size=wx.Size(304, 24),
              style=0)
        self.choice1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Tahoma'))

        self.button3 = wx.Button(id=wxID_FRAME_EFETUARPAGAMENTOBUTTON3,
              label=u'Efetuar Pagamento', name='button3', parent=self.panel1,
              pos=wx.Point(32, 480), size=wx.Size(128, 32), style=0)
        self.button3.Bind(wx.EVT_BUTTON, self.OnButton3Button,
              id=wxID_FRAME_EFETUARPAGAMENTOBUTTON3)

        self.button4 = wx.Button(id=wxID_FRAME_EFETUARPAGAMENTOBUTTON4,
              label=u'Cancelar', name='button4', parent=self.panel1,
              pos=wx.Point(168, 480), size=wx.Size(72, 32), style=0)
        self.button4.Bind(wx.EVT_BUTTON, self.OnButton4Button,
              id=wxID_FRAME_EFETUARPAGAMENTOBUTTON4)

        self.listBox1 = wx.ListBox(choices=[],
              id=wxID_FRAME_EFETUARPAGAMENTOLISTBOX1, name='listBox1',
              parent=self.window2, pos=wx.Point(16, 32), size=wx.Size(224, 176),
              style=0)

    def __init__(self, parent, user, ID):
        self._init_ctrls(parent)
        
        Modos = ['Dinheiro', 'Visa Credito', 'Visa Credito em 2x', 'Visa Credito em 3x', 'Visa Eletron', 'Master Credito','Master Credito em 2x', 'Master Credito em 3x','Hiper Credito','Hiper Credito em 2x','Hiper Credito em 3x', 'Rede Shop']
        for x in Modos:
            self.choice1.Append(x)
                
        if ID != None:
            self.total = 10.00
            self.ID = ID
            
            self.button1.Enable(False)
            self.button2.Enable(False)
            
            ca = ControleAgendamento()
            cs = ControleServico()
            print self.ID
            agendamento = ca.procurarAgendamentoID(self.ID)
            
            for servico in agendamento.GetServicosDoAgendamento():
                self.total += float(cs.procurarPrecoServicoNome(servico))
                self.listBox1.Append(servico)            
                self.staticText7.SetLabel(str(self.total))
                self.staticText7.Show(True)
            
                self.staticText3.SetLabel(agendamento.GetCliente())
                self.staticText3.Show(True)
                
                self.staticText2.SetLabel(self.ID)
                self.staticText2.Show(True)
        
        self.agendamento = agendamento

    def OnButton4Button(self, event):
        import Frame_Pagamento
        Frame_Pagamento.create(None).Show()
        self.Close()

    def OnButton1Button(self, event):
        import Frame_SeleCLi
        Frame_SeleCLi.create(None).Show()
        self.Close()

    def OnButton3Button(self, event):
        ca = ControleAgendamento()
        cp = ControlePagamento()
        
        ID = cp.GerarNovoID()
        Cliente = self.staticText3.GetLabel()
        Servicos = self.listBox1.GetItems()
        
        pos = self.choice1.GetCurrentSelection()
        ModoDePagamento = self.choice1.GetString(pos)
        
        Valor = self.staticText7.GetLabel()
        
        cp.cadastrarPagamento(ID, Cliente, Servicos, ModoDePagamento, Valor)
        
        wx.MessageBox('Receita Cadastrada Com Sucesso', 'Pagamento', wx.OK)
        
        ca.alterarConclusao(ID)
        
        import Frame_Pagamento
        Frame_Pagamento.create(None).Show()
        self.Close()
        
